package com.zy.web.demo.duoxiancheng.demo25;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author <a href="mailto:zhouyong@cqyyt.com">zy</a>
 * @version 1.0
 * @date 2020/8/26 14:32
 */
public class Thread25 {

    private Lock lock = new ReentrantLock();

    public void test(){
        lock.lock();
        try {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName()+","+i);
            }
       }catch (Exception e){
           e.printStackTrace();
       }finally {
           lock.unlock();
       }
    }


}
